package com.tj.jinzao.activity;


import android.content.Intent;
import android.widget.TextView;

import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.auth.AuthService;
import com.tj.jinzao.R;
import com.tj.jinzao.base.BaseActivity;
import com.tj.jinzao.common.Settings;
import com.tj.jinzao.manager.UserManager;
import com.tj.jinzao.utils.DataCacheUtils;
import com.tj.jinzao.utils.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 设置页面
 * Created by wjy on 2019/1/5.
 */
public class SettingsActivity extends BaseActivity {

    @BindView(R.id.tv_cache)
    TextView mCacheView;

    @Override
    public int getLayoutResource() {
        return R.layout.activity_setting;
    }

    @Override
    protected void setupView() {
        super.setupView();
        mCacheView.setText(DataCacheUtils.getTotalCacheSize(this));
    }

    @Override
    protected int getLeftButtonResId() {
        return R.mipmap.ic_back;
    }

    @OnClick(R.id.rl_person_data_layout)
    public void setPersonInfo() {
        startActivity(new Intent(this, PersonInfoActivity.class));
    }

    @OnClick(R.id.rl_accout_layout)
    public void accountManager() {
        startActivity(new Intent(this, AccountManagerActivity.class));
    }

    @OnClick(R.id.rl_notify_layout)
    public void notifyMessage() {

    }

    @OnClick(R.id.rl_network_layout)
    public void network() {
        startActivity(new Intent(this, NetworkSettingActivity.class));
    }

    @OnClick(R.id.rl_cache_layout)
    public void clearCache() {
        DataCacheUtils.clearAllCache(this);
        mCacheView.setText(DataCacheUtils.getTotalCacheSize(this));
        ToastUtils.showToast(this, "清理完毕");
    }

    @OnClick(R.id.rl_service_layout)
    public void service() {
        startActivity(new Intent(this, ServiceQuestionActivity.class));
    }

    @OnClick(R.id.rl_about_layout)
    public void about() {
        startActivity(new Intent(this, AboutActivity.class));
    }

    @OnClick(R.id.rl_quit_layout)
    public void quit() {
        UserManager.userLogout();
        Settings.clearUserData(this);
//        User user = UserManager.getInstance().getUser();
//        user.setExit(1);
//        UserManager.saveUserData(user);
        NIMClient.getService(AuthService.class).logout();
        startActivity(new Intent(this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK));
    }
}
